import request from "@/utils/request"
import commonJs from "@/utils/common"
import ports from "@/utils/ports"


export default {

	getTreeList(data = {}) {
		data = commonJs.obj.removeNullKey(data)
		return request({
			url: ports.api.auth.getTree,
			method: "post",
			data
		})
	},

	save(data) {
		data = commonJs.obj.copyByKey(data, [
			"id",
			"api_name",
			"pid",
			"is_checked",
			"remark",
			"status",
			"type",
			"url",
		])
		return request({
			url: ports.api.auth.edit,
			method: "post",
			data
		})
	},
	apply(data){
		data = commonJs.obj.copyByKey(data, [
			"id",
			"action",
			"nodes",
		])
		return request({
			url: ports.api.auth.apply,
			method: "post",
			data
		})
	},
	del(id) {
		return request({
			url: ports.api.auth.del,
			method: "post",
			data: {
				id
			}
		})
	},
}
